package com.huawei.appgallery.agreementimpl.view.activity;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.InflateException;
import android.view.KeyEvent;
import android.view.View;
import com.huawei.hmf.annotation.ActivityDefine;
import com.huawei.secure.android.common.intent.SafeBroadcastReceiver;
import com.huawei.secure.android.common.intent.SafeIntent;
import o.awg;
import o.awj;
import o.axg;
import o.ayq;
import o.ayw;
import o.ayy;
import o.dof;
import o.ActivityUtil;

@ActivityDefine(alias = "AgreementWebViewActivity")
public class WebViewActivity extends Activity {
    private static final String ˊ = WebViewActivity.class.getSimpleName();
    private ayq ˎ = new ayq();
    private final SafeBroadcastReceiver ॱ = new SafeBroadcastReceiver(this) {
        final /* synthetic */ WebViewActivity ˎ;

        {
            this.ˎ = r1;
        }

        public void onReceiveMsg(Context context, Intent intent) {
            if (intent != null) {
                if (!"android.intent.action.LOCALE_CHANGED".equals(intent.getAction())) {
                    return;
                }
                if (VERSION.SDK_INT >= 21) {
                    this.ˎ.finishAndRemoveTask();
                } else {
                    this.ˎ.finish();
                }
            }
        }
    };

    protected void onCreate(Bundle bundle) {
        ayy.ˋ().ˎ(getWindow());
        ayw.ˋ((Activity) this, "LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES");
        super.onCreate(bundle);
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction("android.intent.action.LOCALE_CHANGED");
        ActivityUtil.registerReceiver(this, intentFilter, this.ॱ);
        String stringExtra = new SafeIntent(getIntent()).getStringExtra("key_param_url");
        if (ˊ(stringExtra)) {
            this.ˎ.ॱ((Context) this);
            if (ˎ()) {
                this.ˎ.ˋ((Context) this);
                this.ˎ.ˊॱ = stringExtra;
                this.ˎ.ˏ(stringExtra);
                return;
            }
            awg.ˎ.ˊ(ˊ, "setContentView failed");
            finish();
            return;
        }
        awg.ˎ.ˊ(ˊ, "checkUrl invalid");
        finish();
    }

    protected boolean ˎ() {
        try {
            View inflate = getLayoutInflater().inflate(this.ˎ.ʼ(), null);
            setContentView(inflate);
            this.ˎ.ˋ(inflate);
            this.ˎ.ˊ((Activity) this);
            this.ˎ.ˊ(getActionBar());
            return true;
        } catch (InflateException e) {
            Log.e(ˊ, "SetContentView appends InflateException: " + e);
            return false;
        }
    }

    public boolean onKeyUp(int i, KeyEvent keyEvent) {
        if (i != 4) {
            return super.onKeyUp(i, keyEvent);
        }
        if (this.ˎ != null) {
            this.ˎ.ʽ();
        }
        return true;
    }

    protected void onDestroy() {
        super.onDestroy();
        if (this.ˎ != null) {
            this.ˎ.ᐝ();
        }
        if (this.ॱ != null) {
            ActivityUtil.unregisterReceiver((Context) this, this.ॱ);
        }
    }

    protected void onResume() {
        super.onResume();
        if (this.ˎ != null) {
            this.ˎ.ˏॱ();
        }
    }

    protected void onPause() {
        super.onPause();
        if (this.ˎ != null) {
            this.ˎ.ˊॱ();
        }
    }

    public void onConfigurationChanged(Configuration configuration) {
        super.onConfigurationChanged(configuration);
        if (this.ˎ != null) {
            this.ˎ.ˋ(configuration);
            this.ˎ.ˊ((Activity) this);
        }
    }

    private boolean ˊ(String str) {
        if (TextUtils.isEmpty(str)) {
            return false;
        }
        if (this.ˎ != null) {
            this.ˎ.ˎ(false);
        }
        awj ˏ = axg.ˏ();
        if (!dof.ˋ(ˏ.ˊ()) && str.equals(ˏ.ˊ())) {
            return true;
        }
        if (!dof.ˋ(ˏ.ˏ()) && str.equals(ˏ.ˏ())) {
            return true;
        }
        if (dof.ˋ(ˏ.ˎ()) || !str.equals(ˏ.ˎ())) {
            return false;
        }
        if (this.ˎ != null) {
            this.ˎ.ˎ(true);
        }
        return true;
    }
}
